import java.awt.*;


public class AStarNode {

	// Node information
	Point grid_pos;
	AStarNode parent;
	
	// Cost information
	double f, g, h;	// f = g + h
					// g = cost from starting point till here
					// h = guessed cost from here to end
	
	public AStarNode(Point pos, AStarNode parent, double gcost, Point end) {
		grid_pos = pos;
		this.parent = parent;
		calcG(gcost);
		calcH(end);
		calcF();
	}
	
	public void calcG(double cost) {
		if(parent != null)
			g = parent.g + cost;
		else
			g = 0;
	}
	
	public void calcH(Point end) {
		// Manhatten Methode
		double relx = grid_pos.x - end.x;
		double rely = grid_pos.y - end.y;
		
		h = (Math.abs(relx) + Math.abs(rely))*10;
	}
	
	public void calcF() {
		f = g + h;
	}

}
